
<%@ page import="org.xilin.Book" %>

<g:setProvider library="jquery"/>

<div>
  
    <g:if test="${flash.message}">
        <div class="message" style="display:none">${flash.message}</div>
    </g:if>
    <g:hasErrors bean="${bookInstance}">
        <div class="errors">
            <g:renderErrors bean="${bookInstance}" as="list" />
        </div>
    </g:hasErrors>
    <g:formRemote name="saveBook" url="${[action:'save']}" method="post" update="cluetip-inner" onSuccess="" before="beforeSave()" onComplete="processResponse()">
        <g:hiddenField name="id" value="${bookInstance?.id}" />
        <g:hiddenField name="version" value="${bookInstance?.version}" />
        <g:hiddenField name="view" value="edit" />
        <div>
            <table>
                <tbody>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="name"><g:message code="book.name.label" default="Name" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: bookInstance, field: 'name', 'errors')}">
                            <g:textField name="name" value="${bookInstance?.name}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="category"><g:message code="book.category.label" default="Category" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: bookInstance, field: 'category', 'errors')}">
                            <g:select name="category" from="${bookInstance?.categories}" value="${bookInstance?.category}"/>
                        </td>
                    </tr>
                
                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="description"><g:message code="book.description.label" default="Description" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: bookInstance, field: 'description', 'errors')}">
                            <g:textField name="description" value="${bookInstance?.description}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="price"><g:message code="book.price.label" default="Price" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: bookInstance, field: 'price', 'errors')}">
                            <g:textField name="price" value="${fieldValue(bean: bookInstance, field: 'price')}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="extraFee">
                            <label for="price"><g:message code="book.extraFee.label" default="extraFee" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: bookInstance, field: 'extraFee', 'errors')}">
                            <g:textField name="extraFee" value="${fieldValue(bean: bookInstance, field: 'extraFee')}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="stock"><g:message code="book.stock.label" default="Stock" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: bookInstance, field: 'stock', 'errors')}">
                            <g:textField name="stock" value="${fieldValue(bean: bookInstance, field: 'stock')}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                          <label for="reserve"><g:message code="book.reserve.label" default="Reserve" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: bookInstance, field: 'reserve', 'errors')}">
                            <g:textField name="reserve" value="${fieldValue(bean: bookInstance, field: 'reserve')}" />
                        </td>
                    </tr>

                    <tr class="prop">
                        <td valign="top" class="name">
                            <label for="semester.id"><g:message code="book.semester.label" default="Semester" /></label>
                        </td>
                        <td valign="top" class="value ${hasErrors(bean: bookInstance, field: 'semester', 'errors')}">
                            <g:select name="semester.id" from="${org.xilin.Semester.list()}" optionKey="id" value="${bookInstance?.semester?.id}"  />
                        </td>
                    </tr>

                </tbody>
            </table>
        </div>
        <div class="buttons">
            <span class="button"><g:actionSubmit class="save" action="update" value="${message(code: 'default.button.update.label', default: 'Update')}" /></span>
            <span class="button"><input type="reset" value="${message(code: 'default.button.clear.label', default: 'Reset')}" /></span>
        </div>
    </g:formRemote>
</div>
